1. Field of the Invention
The present invention relates generally to transaction support in a distributed object computing environment and more particularly, to a method for distributed transaction support using JDBC 1.0 drivers.
2. Description of the Related Art
Java DataBase Connectivity or JDBC is a generic SQL database access applications program interface (API) for the Java programming language. This API provides a uniform interface to a variety of different database modules, allowing programmers to write a single database interface for accessing a variety of different databases. The original JDBC 1.0 specification has recently been updated by the release of a JDBC 2.0 core API specification, version 1.0, May 30, 1998 and a JDBC 2.0 Standard Extension API specification, version 1.0, Dec. 7, 1998, the disclosures of which are herein incorporated by reference.
As shown in FIG. 1, when a database connection is obtained from a JDBC 1.0 driver, all database accesses done through that connection will be performed by the transaction specific to that connection. For example, if there are three database connections C1, C2, C3 the work done through the three connections will be isolated into three separate, independent transactions T1, T2, T3.
The JDBC 2.0 Standard Extension API defines support for distributed transactions using the standard two-phase commit protocol defined in the Java Transaction API (JTA). This feature allows multiple JDBC connections to multiple databases to be coordinated under the same global transaction. In other words, a series of work by individual components is grouped into one single unit of work, i.e. a single transaction. For example, as illustrated in FIG. 2, with a JDBC 2.0 Standard Extension driver it is possible to obtain multiple database connections C4, C5, C6 such that they are all enlisted in the same global transaction T4. In other words, all the work done through these connections C4, C5, C6 are part of the same global transaction T4.
Support for the JDBC 2.0 Standard Extension API, however, is optional and many databases only provide JDBC 1.0 drivers. The JDBC 1.0 drivers do not include distributed transaction support as defined in the JDBC 2.0 Standard Extension. It would thus be desirable to provide limited distributed transaction support using JDBC 1.0 drivers, without the need for a JDBC 2.0 Standard Extension compatible driver.
The present invention provides design and implementation of classes that allow the simulation of JDBC 2.0 Standard Extension driver behavior using standard JDBC 1.0 drivers. Instead of creating a new physical database connection for each connection request, an interface driver internally maintains a mapping in a table between a global transaction identifier and the physical database connection. Even if an application requests multiple connections to the same database, all database access through those connections are actually re-directed to the same physical database connection as maintained in the table. This allows all the work to be coordinated under the same transaction.
First, an adapter maintains a table of mappings between global transaction identifiers and associated physical connections. When a component requests a database connection, the component is assigned a virtual connection. When the component attempts to access the connection, the adapter determines whether a physical connection is associated with the component""s transaction. If not, a new physical connection is created and the table is updated. The component""s virtual connection is then dynamically wired to the physical connection associated with the component""s transaction. Thus, the component""s access is redirected to the physical connection. From the database point of view, only one physical connection is established and is associated with only one transaction. The work performed by the different components is thereby automatically grouped under the same transaction.
The present invention will be readily understood by the following detailed description in conjunction with the accompanying drawings, wherein like reference numerals designate like structural elements, and in which:
FIG. 1 illustrates database connections made according to a JDBC 1.0 driver;
FIG. 2 illustrates database connections made according to a JDBC 2.0 driver;
FIG. 3 is a diagram of a typical J2EE RI implementation;
FIG. 4 is illustrating the relationship between a container, components, a JDBC driver and a database;
FIG. 5 (A) illustrates a container configured using a JDBC 2.0 driver;
FIG. 5 (B) illustrates a container configured according to the present invention;
FIG. 6 illustrates a preferred embodiment of the present invention; and
FIG. 7 is a flow chart of the operation of the present invention.